package com.badlogicgames.superjumper;
import com.badlogic.gdx.math.Vector2;

public class Bullet extends DynamicGameObject {
    public static final float VELOCITY=10f;
    float direction;
    int state;
    float stateTime;
    public static final float BULLET_HEIGHT = 0.5f;
    public static final float BULLET_WIDTH = 0.5f;
    
	public Bullet(float x, float y, float rotation) {
		super(x, y, BULLET_WIDTH, BULLET_HEIGHT);
		velocity.set(VELOCITY, VELOCITY);
		this.direction = rotation;
		
//		if (direction>=90)
//		{			
			velocity.x=(float) (VELOCITY*(float) Math.cos((direction)*3.1415/180));
        	velocity.y=(float) (VELOCITY* (float)Math.sin((direction)*3.1415/180));
//		}
//        	else
//		{			
//			velocity.x=(float) (VELOCITY*(float) Math.tan((direction-90)*3.1415/180));
//        	velocity.y=(float) (VELOCITY* (float)Math.tan((direction-180)*3.1415/-180));
//		}
        	position.add((Turret.WIDTH*(float) Math.cos((rotation)*3.1415/180)),+ (Turret.WIDTH* (float)Math.sin((rotation)*3.1415/180)));


	}
	
	public void update(float deltaTime) {
		//update velocity here.
		//this.velocity = something ali will calculate;
	
//        position.add(this.velocity.x*deltaTime , this.velocity.y*deltaTime);
		
		
		// explosion happen when the bullet 
		// vibrate the phone with explosion
        position.add(this.velocity.x *deltaTime, this.velocity.y*deltaTime);
        bounds.x = position.x - BULLET_WIDTH / 2;
        bounds.y = position.y - BULLET_HEIGHT / 2;
        stateTime += deltaTime;        
	}

}
